Security News
NVD Backlog Tops 20,000 CVEs Awaiting Analysis as NIST Prepares System Updates
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
rc-virtual-list
Advanced tools
The rc-virtual-list npm package is a React component for efficiently rendering large lists and tabular data. It only renders the items that are currently visible in the viewport, which helps in improving the performance of the application by reducing the number of DOM nodes.
Basic Virtual List
This code sample demonstrates how to create a basic virtual list with fixed item height. The 'data' prop is an array of items to display, 'height' sets the height of the list, 'itemHeight' is the height of each item, and 'itemKey' is a unique key for each item.
import VirtualList from 'rc-virtual-list';
<VirtualList
data={data}
height={200}
itemHeight={20}
itemKey='id'
>{(item) => <div>{item.name}</div>}</VirtualList>
Dynamic Item Height
This code sample shows how to handle dynamic item heights. The 'style' parameter is used to apply necessary styles for positioning items in the virtual list.
import VirtualList from 'rc-virtual-list';
<VirtualList
data={data}
height={200}
itemKey='id'
>{(item, index, style) => (
<div style={style}>{item.name}</div>
)}</VirtualList>
Custom Scrollbar
This example illustrates how to integrate a custom scrollbar component into the virtual list. The 'components' prop allows you to replace the default scrollbar with a custom one.
import VirtualList from 'rc-virtual-list';
import CustomScrollbar from 'custom-scrollbar-component';
<VirtualList
data={data}
height={200}
itemHeight={20}
itemKey='id'
components={{
scrollbar: CustomScrollbar
}}
>{(item) => <div>{item.name}</div>}</VirtualList>
React-window is a similar package that provides components for efficiently rendering large lists and tabular data. It is similar to rc-virtual-list but offers a different API and additional features like variable item sizes and direction support (horizontal/vertical).
React-virtualized is another package that offers a set of components for efficiently rendering large lists, grids, and tables. It is more feature-rich than rc-virtual-list, providing features like cell measuring and window scroller integration, but it may be heavier in terms of bundle size.
Virtuoso is a React virtual list component with a different set of features, including automatic item size measurements, group headers, and end-to-end list buffering. It provides a more out-of-the-box experience compared to rc-virtual-list, which is more low-level and customizable.
React Virtual List Component which worked with animation.
https://virtual-list-react-component.vercel.app/
npm install
npm start
open http://localhost:9001/
import List from 'rc-virtual-list';
<List data={[0, 1, 2]} height={200} itemHeight={30} itemKey="id">
{index => <div>{index}</div>}
</List>;
Prop | Description | Type | Default |
---|---|---|---|
children | Render props of item | (item, index, props) => ReactElement | - |
component | Customize List dom element | string | Component | div |
data | Data list | Array | - |
disabled | Disable scroll check. Usually used on animation control | boolean | false |
height | List height | number | - |
itemHeight | Item minium height | number | - |
itemKey | Match key with item | string | - |
styles | style | { horizontalScrollBar?: React.CSSProperties; horizontalScrollBarThumb?: React.CSSProperties; verticalScrollBar?: React.CSSProperties; verticalScrollBarThumb?: React.CSSProperties; } | - |
children
provides additional props
argument to support IE 11 scroll shaking.
It will set style
to visibility: hidden
when measuring. You can ignore this if no requirement on IE.
FAQs
React Virtual List Component
The npm package rc-virtual-list receives a total of 1,247,854 weekly downloads. As such, rc-virtual-list popularity was classified as popular.
We found that rc-virtual-list demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.